package com.red.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;

import po.User;

/**
* Created By lijiliang on 2018年7月13日 下午11:59:19
*/
@Controller
public class MyController {
	
	@RequestMapping(value="/modifyUsr",method= {RequestMethod.POST},consumes= {"application/json"},
			produces= {"application/json"})
	@ResponseBody
	public Object addEmpGetStu(@RequestBody User user)throws Exception{
		
		JSONObject responseObj = (JSONObject) JSONObject.toJSON(user);
		System.out.println(responseObj);
		return responseObj;
	}
	
	@RequestMapping(value="/findStu")
	@ResponseBody
	public Object findStu()throws Exception{
		List<User> list = new ArrayList<>();
		list.add(new User("张三","男",23));
		list.add(new User("张三2","男",24));
		list.add(new User("张三3","男",25));
		//JSONObject reJsonObject = (JSONObject) JSONObject.toJSON(list);
		return list;
	}
}
